#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 4) {
        cout << "Usage: " << argv[0] << " file word1 word2" << endl;
        return 0;
    }

    string file_name(argv[1]);
    string word1(argv[2]);
    string word2(argv[3]);

    int min_dist;
    int min_dist_word1_loc;
    int min_dist_word2_loc;
    min_dist = calcShortestDist(file_name.c_str(), 
                                word1.c_str(),
                                word2.c_str(),
                                min_dist_word1_loc,
                                min_dist_word2_loc);
    if (min_dist == -1) {
        if (min_dist_word1_loc == -1 &&
            min_dist_word2_loc == -1) {
            cout << "Both word1 and word2 do not exist in the file!" << endl;
        }
        else if (min_dist_word1_loc == -1) {
            cout << "Word1 does not exist in the file!" << endl;
        }
        else {
            cout << "Word2 does not exist in the file!" << endl;
        }
    }
    else {
        cout << "Shortest dist of word1 and word2 is " << min_dist << "." << endl;
        cout << "Word1 loc is " << min_dist_word1_loc << "." << endl;
        cout << "Word2 loc is " << min_dist_word2_loc << "." << endl;
    }

    return 0;
}

